<!-- 待收来电 > 收电登记-->
<template>
  <view>
    <van-popup v-model="showCompo" closeable round position="bottom" :style="{ height: '100%' }"
               @click-close-icon="toClose" @click-overlay="toClose">
      <van-row type="flex" justify="center">
        <van-col offset="1" span="8">
          <van-cell value="收电登记"/>
        </van-col>
      </van-row>
      <van-form @submit="onSubmit">
        <van-cell-group inset>
          <van-field
              v-model="formData.title"
              name="title"
              label="标题"
              required
              placeholder="请输入内容"
              input-align="right"
              :rules="[{ required: true, message: '请填写标题' }]"
          />

          <van-cell title="主办" :value="formData.mainToName" is-link @click="showOrgTreeSheet('mainTo')"/>
          <!-- forwardType:mainTO：主办，copyTo：抄送 -->
          <orgTree :showOrgTree="showOrgTreeMain" :nodeData="nodeDataMain" forwardType="mainTo"
                   @closeOrgTreeSheet="closeOrgTreeSheet"></orgTree>

          <van-cell title="抄送" :value="formData.copyToName" forwardType="copyTo" is-link
                    @click="showOrgTreeSheet('copyTo')"/>
          <orgTree :showOrgTree="showOrgTreeCopy" :nodeData="nodeDataCopy" forwardType="copyTo"
                   @closeOrgTreeSheet="closeOrgTreeSheet"></orgTree>

          <van-field
              v-model="formData.otherUnit"
              name="otherUnit"
              label="其他单位"
              placeholder="清输入内容"
              input-align="right"
          />

          <van-cell title="转发单位" :value="formData.forwardUnitName" forwardType="copyTo" is-link
                    @click="showOrgTreeSheet('forward')"/>
          <orgTree :showOrgTree="showOrgTreeForward" :nodeData="nodeDataForward" forwardType="forward"
                   @closeOrgTreeSheet="closeOrgTreeSheet"></orgTree>


          <van-cell is-link title="等级" :value="formData.emergencyLevelName" @click="showEmergency = true"/>
          <van-action-sheet v-model="showEmergency" :actions="emergencySelect" cancel-text="取消"
                            @select="onSelectElergency"/>

          <van-cell is-link title="重要电报" :value="formData.attentionStatusName" @click="showAttention = true"/>
          <van-action-sheet v-model="showAttention" :actions="attentionSelect" cancel-text="取消"
                            @select="onSelectAttention"/>

          <view class="opinion">
            <text class="opinion-left">处理分类</text>
            <view class="opinion-right">
              <van-checkbox-group v-model="result" direction="horizontal" @change="toggle">
                <van-checkbox name="0" icon-size="32rpx" shape="square">紧急重要需加急办理</van-checkbox>
              </van-checkbox-group>
            </view>
          </view>

          <van-cell is-link title="文种" :value="this.dict.getDictNameByDictCode('swLanguage',formData.language)" @click="showLanguage = true"/>
          <van-action-sheet v-model="showLanguage" :actions="languageSelect" cancel-text="取消"
                            @select="onSelectLanguage"/>

          <van-cell is-link title="收电来源" :value="this.dict.getDictNameByDictCode('source',formData.sdSource)" @click="showSource = true"/>
          <van-action-sheet v-model="showSource" :actions="sourceSelect" cancel-text="取消"
                            @select="onSelectSource"/>

          <van-cell is-link title="收电内容" :value="this.dict.getDictNameByDictCode('content',formData.sdContent)" @click="showContent = true"/>
          <van-action-sheet v-model="showContent" :actions="contentSelect" cancel-text="取消"
                            @select="onSelectContent"/>

          <van-field v-model="sdh" name="sdh" label="收电号" readonly input-align="right"/>

          <view class="opinion">
            <text class="opinion-left">预计收号</text>
            <view class="opinion-right">
              <text>{{ formData.sdWord }}</text>
              <text>〔{{ formData.sdYear }}〕</text>
              <text>{{ formData.sdNum }}号</text>
            </view>
          </view>

          <van-field
              v-model="formData.sdTime"
              readonly
              label="收电时间"
              placeholder="点击选择日期"
              @click="showPopFn"
              input-align="right"
          />
          <van-popup v-model="showPop" round position="bottom" :style="{ height: '40%' }">
            <van-datetime-picker
                v-model="currentDate"
                type="datetime"
                @change="changeFn()"
                @confirm="confirmFn()"
                @cancel="cancelFn()"
            />
          </van-popup>

          <van-cell>
            <van-row type="flex">
              <van-col span="6" class="box-input">
                <span>份数/页数</span>
              </van-col>
              <van-col span="6" class="box-input">
                批办<input class="piban-input" type="digit" v-model="formData.approvePart"/>份,
              </van-col>
              <van-col span="6" class="box-input">
                转发<input class="piban-input" type="digit" v-model="formData.forwardPart"/>份,
              </van-col>
              <van-col span="6" class="box-input">
                每份<input class="piban-input" type="digit" v-model="formData.eachPage"/>页
              </van-col>
            </van-row>
          </van-cell>


          <van-field
              v-model="formData.fdDeptName"
              name="fdDeptName"
              label="来电单位"
              required
              readonly
              input-align="right"
          />
          <van-field
              v-model="formData.fdNum"
              name="fdNum"
              label="来电号"
              required
              readonly
              input-align="right"
          />

          <view class="opinion">
            <text class="opinion-left">正文</text>
            <view class="opinion-right" v-if="this.util.isNotEmpty(detailBody.all)">
              <text v-for="(item,index) in detailBody.all" @click="lx.openFile(item, formData.annexId)" class="text-blue">{{ formData.title }}</text>
            </view>
          </view>
          <view class="opinion">
            <text class="opinion-left">附件</text>
            <view class="opinion-right" v-if="detailAttachment.length>0">
              <text v-for="(item,index) in detailAttachment" class="text-blue" @click="lx.openFile(item, formData.annexId)">{{item.attachName}}</text>
            </view>
          </view>

          <van-field
              v-model="formData.drafterName"
              name="drafterName"
              readonly
              label="拟稿人"
              input-align="right"
          />
          <van-field
              v-model="formData.drafterPhone"
              name="drafterPhone"
              readonly
              label="电话"
              input-align="right"
          />
          <van-field
              v-model="formData.drafterDeptName"
              name="drafterDeptName"
              readonly
              label="拟稿单位"
              input-align="right"
          />
          <van-field
              v-model="formData.registerName"
              name="registerName"
              readonly
              label="登记人"
              readonly
              input-align="right"
          />

          <van-field
              v-model="formData.remark"
              rows="3"
              autosize
              label="备注"
              type="textarea"
              placeholder=""
              clearable
              input-align="right"
          />


        </van-cell-group>
        <view style="margin: 40rpx;height: 160rpx;">
          <van-row type="flex" justify="space-around">
            <van-col span="10">
              <van-button type="info" round plain hairline block @click.prevent="toClose">取消</van-button>
            </van-col>
            <van-col span="10">
              <van-button type="info" round block native-type="submit">确定</van-button>
            </van-col>
          </van-row>
        </view>

      </van-form>
    </van-popup>
  </view>
</template>

<script>
import csld from 'pages/caac/components/receiveMsgDoc/compo-csld';//呈送领导选择组件
import approve from 'pages/caac/components/receiveMsgDoc/compo-approve';//批办人选择组件
import orgTree from 'pages/caac/components/receiveMsgDoc/compo-orgtree';//主办组件
export default {
  components: {
    csld,
    approve,
    orgTree
  },
  props: {
    showRegister: {
      type: Boolean,
      default: false
    },
  },
  data() {
    return {
      showCsld: false,//呈送领导选择组件
      showApprove: false,//批办人选择组件
      showCompo: false,//组件是否显示

      csldList: [],//呈送领导list
      csldName: [],//选中的呈送领导，以逗号分割
      csldId: [],//选中的呈送领导id，以逗号分割

      // approveToName:'',//回显的批办人名称，因表单中不存在name字段
      approveName: [],//选中的批办人，以逗号分割
      approveTo: [],//选中的批办人id，以逗号分割
      approveList: [],//批办人

      showOrgTreeMain: false,//主办组件显示
      showOrgTreeCopy: false,//抄送组件显示
      showOrgTreeForward: false,//转发单位显示

      //主送显示和隐藏哪些节点
      nodeDataMain: {
        showNode: '',//显示的节点
        hideNode: '',//隐藏的节点
      },
      //抄送
      nodeDataCopy: {
        showNode: '',//显示的节点
        hideNode: '',//隐藏的节点
      },
      //转发单位显示所有单位
      nodeDataForward: {
        showNode: '',
        hideNode: ''
      },
      sdh: '(系统生成)',
      formData: {
        "bizType": "",
        "approvePart": "",
        "fdDeptName": "",
        "draftStatus": "",
        "psfsDept": "",
        "approveTo": "",
        "approveToName": "",
        "attentionStatus": "",//重要电报1-是，0-否
        "attentionStatusName": "",
        "remark": "",
        "title": "",
        "mainTo": "",
        "mainToName": "",
        "copyTo": "",
        "copyToName": "",
        "forwardUnit": "",
        "forwardUnitName": "",
        "forwardPart": "",
        "updateId": "",
        "drafterPhone": "",//电话
        "eachPage": "",
        "emergencyLevel": "",
        "emergencyLevelName": "",
        "officeId": "",
        "registerId": "",
        "registerName": "",//登记人
        "fdId": "",
        "drafterDeptName": "",
        "sdTime": "",
        "approvalId": "",
        "forwardStatus": "",
        "sdWord": "",
        "sdYear": "",
        "sdNum": "",
        "approvalStatus": "",
        "importStatus": "",//处理分类--紧急重要需加急办理
        "fdNum": "",
        "leaderType": "",
        "proInstId": "",
        "otherUnit": "",
        "createTime": "",
        "csldTo": "",
        "csldToName": "",
        "archiveStatus": "",
        "delStatus": "",
        "sdId": "",
        "sendStatus": "",
        "deleterId": "",
        "drafterId": "",//拟稿人id
        "drafterName": "",//拟稿人
        "status": "",
        "completeTime":'',
        "language":'',//文种
        "sdContent":'',
        "sdSource":'',
        "updateTime":''
      },
      detailBody: {},//正文
      detailAttachment: [],//附件
      //字典相关
      showEmergency: false,//等级
      emergencySelect: [],
      showLanguage: false,
      languageSelect: [],
      showSource: false,
      sourceSelect: [],
      showContent: false,
      contentSelect: [],

      showAttention: false,//重要电报
      attentionSelect: [
        {"name": "否", "dictItemCode": 0},
        {"name": "是", "dictItemCode": 1}
      ],
      showCalendar: false,
      value: '',
      result: [],//处理分类复选框选中的值
      showPop: false,
      currentDate: new Date(),
      changeDate: new Date(),
      configForStart: {},//提交表单所需参数
      wfmData: {},//提交返回的参数，调用listNextActivity接口
      endGongWen: [],
      //uuid 和sdId 接口 caac/oa/doc/hbglj/fdpengding/registerType用
      uuid: '',//
      sdId: '',

    }
  },
  mounted() {
    //赋值
    this.initFormData()


    this.getDict()//初始化字典
    this.fdword()//获取发电字头
    this.approveinfo()//获取呈送领导和批办人
    this.cuserdept()
  },
  watch: {
    showRegister(val) {
      this.showCompo = val
    },
  },
  methods: {

    //表单数据初始化
    initFormData() {
      this.formData.bizType = 'hbgljsd'
      this.formData.approvePart = '1'
      // this.formData.draftStatus = '2'
      this.formData.attentionStatus = '0'//重要电报：1-是，0-否
      this.formData.attentionStatusName = '否'
      this.formData.forwardPart = '0'
      this.formData.eachPage = '1'
      this.formData.emergencyLevel = 'pj'
      this.formData.emergencyLevelName = '平急'
      this.formData.registerName = this.cache.get("userInfo").userName
      this.formData.registerId = this.cache.get("userInfo").userId
      this.formData.sdTime = this.util.timeFormatYYYYMMDDHHMMSS(new Date())
      this.formData.sdYear = this.dict.getCurrentYear()
      // this.formData.approvalStatus='0'
      // this.formData.importStatus='0'
      // this.formData.archiveStatus='2'
      // this.formData.sendStatus='0'
      // this.formData.status='2'
      this.formData.createTime = this.util.timeFormatYYYYMMDDHHMMSS(new Date())
    },
    toggle() {
      if (this.result.length > 0) {
        this.formData.importStatus = 1
      } else {
        this.formData.importStatus = 0
      }
      console.log("this.result: " + JSON.stringify(this.formData.importStatus));
    },
    showPopFn() {
      this.showPop = true
    },
    //等级
    onSelectElergency(item) {
      console.log("item: " + JSON.stringify(item));
      this.formData.emergencyLevel = item.dictItemCode
      this.formData.emergencyLevelName = item.name
      this.showEmergency = false;
    },
    // 文种
    onSelectLanguage(item) {
      this.formData.language = item.dictItemCode
      this.showLanguage = false;
    },
    // 来源
    onSelectSource(item) {
      this.formData.sdSource = item.dictItemCode
      this.showSource = false;
    },
    // 内容
    onSelectContent(item) {
      this.formData.sdContent = item.dictItemCode;
      this.showContent = false;
    },

    //重要电报
    onSelectAttention(item) {
      this.formData.attentionStatus = item.dictItemCode
      this.formData.attentionStatusName = item.name
      this.showAttention = false
    },
    //显示呈送领导组件
    showCsldSheet() {
      this.showCsld = true
    },
    //关闭呈送领导组件（子组件调用）
    closeCsldSheet(result) {
      console.log("result: " + JSON.stringify(result));
      //result 为子页面传回来的选中的人的数组[{"userId":"10701","userCode":"chenguangcheng_hb","userName":"陈广承","sex":"1","sort":21,"birthday":null,"secretLevel":null,"officePhone":null,"mobilePhone":"13701208132","fax":null,"email":"chenguangcheng_hb@caac.net","zwId":null,"directLeader":null,"idCard":null,"theme":null,"extend1":"002001026","extend2":null,"extend3":null,"extend4":null,"extend5":null,"extend6":"10701","extend7":null,"extend8":null,"extend9":null,"extend10":null,"isValid":"1","createUser":"CAAC_SYSTEM","createTime":"2021-07-27T12:30:00.011+0000","updateUser":"CAAC_SYSTEM","updateTime":"2021-09-02T02:25:00.010+0000"}]

      //重新选择后置空数组，防止重复显示
      this.csldName = []
      this.csldId = []
      if (this.util.isNotEmpty(result)) {
        result.forEach((item) => {
          this.csldName.push(item.userName)
          this.csldId.push(item.userId)
        })
      }
      //赋值回显，以逗号分割
      this.formData.csldToName = this.csldName.toString()
      this.formData.csldTo = this.csldId.toString()

      this.showCsld = false//关闭
    },

    //显示批办人选择组件
    showApproveSheet() {
      this.showApprove = true
    },
    //关闭批办人选择组件（子组件调用）
    closeApproveSheet(result) {
      console.log("result: " + JSON.stringify(result));
      //result 为子页面传回来的选中的人的数组[{"userId":"10701","userCode":"chenguangcheng_hb","userName":"陈广承","sex":"1","sort":21,"birthday":null,"secretLevel":null,"officePhone":null,"mobilePhone":"13701208132","fax":null,"email":"chenguangcheng_hb@caac.net","zwId":null,"directLeader":null,"idCard":null,"theme":null,"extend1":"002001026","extend2":null,"extend3":null,"extend4":null,"extend5":null,"extend6":"10701","extend7":null,"extend8":null,"extend9":null,"extend10":null,"isValid":"1","createUser":"CAAC_SYSTEM","createTime":"2021-07-27T12:30:00.011+0000","updateUser":"CAAC_SYSTEM","updateTime":"2021-09-02T02:25:00.010+0000"}]

      //重新选择后置空数组，防止重复显示
      this.approveToName = ''
      this.approveName = []
      this.approveTo = []
      if (this.util.isNotEmpty(result)) {
        result.forEach((item) => {
          this.approveName.push(item.userName)
          this.approveTo.push(item.userId)
        })
      }
      //赋值回显，以逗号分割
      this.formData.approveToName = this.approveName.toString()
      this.formData.approveTo = this.approveTo.toString()
      this.showApprove = false//关闭
    },
    //主办抄送转发单位
    showOrgTreeSheet(type) {
      if (type == 'mainTo') {
        this.showOrgTreeMain = true
      } else if (type == 'copyTo') {
        this.showOrgTreeCopy = true
      } else {//type=='forward'
        this.showOrgTreeForward = true
        this.nodeDataForward.showNode = ''
      }

    },
    /**
     * 子组件调用，通知父组件关闭当前子组件
     * @param {Object} orgInfo 选中的数组对象
     * forwardType   mainTo：主办，copyTo：抄送,forward:转发单位
     * {forwardType:this.forwardType,orgName:this.deptName.toString(),deptCode:this.deptCode.toString()}
     */
    closeOrgTreeSheet(orgInfo) {
      if (this.util.isNotEmpty(orgInfo.forwardType)) {
        if (orgInfo.forwardType == 'mainTo') {//主办
          this.formData.mainToName = ''
          this.formData.mainTo = ''
          if (this.util.isNotEmpty(orgInfo.deptCode)) {
            this.formData.mainToName = orgInfo.orgName
            this.formData.mainTo = orgInfo.deptCode
          }
          this.nodeDataCopy.hideNode=orgInfo.deptCode
          this.showOrgTreeMain = false
        } else if (orgInfo.forwardType == 'copyTo') {//抄送
          this.formData.copyToName = ''
          this.formData.copyTo = ''
          if (this.util.isNotEmpty(orgInfo.deptCode)) {
            this.formData.copyToName = orgInfo.orgName
            this.formData.copyTo = orgInfo.deptCode
          }
          this.nodeDataMain.hideNode=orgInfo.deptCode
          this.showOrgTreeCopy = false
        } else {//if(orgInfo.forwardType == 'forward')
          this.formData.forwardUnitName = ''
          this.formData.orwardUnit = ''
          if (this.util.isNotEmpty(orgInfo.deptCode)) {
            this.formData.forwardUnitName = orgInfo.orgName
            this.formData.forwardUnit = orgInfo.deptCode
          }
          this.showOrgTreeForward = false
        }
      }
    },

    // onConfirm(date){
    //   this.value = `${date.getYear()}/${date.getMonth() + 1}/${date.getDate()}`
    //   this.formData.sdTime = date
    //   this.showCalendar = false
    // },

    onSubmit() {
      //校验-请在批办、主办、抄送、局领导、其他单位、转发单位中至少选择一个
      if (this.util.isEmpty(this.formData.csldTo) && this.util.isEmpty(this.formData.approveTo)
          && this.util.isEmpty(this.formData.mainTo) && this.util.isEmpty(this.formData.copyTo)
          && this.util.isEmpty(this.formData.otherUnit) && this.util.isEmpty(this.formData.forwardUnit)) {
        this.$toast('请在批办、主办、抄送、局领导、其他单位、转发单位中至少选择一个！')
        return
      } else {
        //提交
        this.save()
        console.log("this.formData: " + JSON.stringify(this.formData));
      }
    },

    //提交,提交成功后调listNextActivity接口，再调completeWorkitem接口
    save() {
      // this.tuiGongWen[0].participants='user:'+this.gwSercet.userId
      const _this = this
      this.$httploading({
        url: this.$http.adornUrl(`/caac/wfm/ApplicationController/save`),
        method: 'post',
        params: {
          'systemKey': this.cache.get('userInfo').systemKey,//固定值
          'systemFlag': this.cache.get('userInfo').systemFlag,//固定值
          data: this.$http.adornData({
            'sdForm': this.formData,
            'wfmData': {
              'configId': this.configForStart.inputActivity.configId,
              'proDirId': this.configForStart.inputActivity.proDirId,
              'actDefId': this.configForStart.inputActivity.actDefId,
              // 'configCode': 'hbgljsdzlc'
            }
          }),
        }
      }).then(({data}) => {
        console.log("提交保存结果-->>: " + JSON.stringify(data));
        if (data.code == 200) {
          this.wfmData = data.data.wfmData//

          this.listNextActivities()
          this.sdId = data.data.sdForm.sdId
          this.registerType()
          // _this.$toast("操作成功")
          uni.redirectTo({
            url: '/pages/caac/receiveMsg/receive-call'
          })
        } else {
          _this.$toast(data.message + ' code:' + data.code)
        }

      })

    },
    registerType() {
      const _this = this
      this.$httploading({
        url: this.$http.adornUrl(`/caac/oa/doc/fdpengding/registerType`),
        method: 'post',
        params: {
          'systemKey': this.cache.get('userInfo').systemKey,//固定值
          'systemFlag': this.cache.get('userInfo').systemFlag,//固定值
        },
        data: this.$http.adornData({
          'sdId': this.sdId,
          'uuid': this.uuid
        })
      }).then(({data}) => {
        console.log("registerType data-->>: " + JSON.stringify(data));
        if (data.code == 200) {

        } else {
          _this.$toast(data.message + ' code:' + data.code)
        }

      })
    },
    //获取流转范围
    listNextActivities() {
      const _this = this
      this.$http({
        url: this.$http.adornUrl(`/caac/wfm/ApplicationController/listNextActivities`),
        method: 'post',
        params: {
          //固定值
          'systemKey': this.cache.get('userInfo').systemKey,//固定值
          'systemFlag': this.cache.get('userInfo').systemFlag,//固定值
          'data': this.$http.adornData({
            //this.wfmData:{"workitemId":"2227eaf491764d31b500bde495f3b0df","actDefId":"draft","isClosePage":false,"configId":"d93865b5a11a481087b3a43618574bf1","configCode":"hbgljsdzlc","proDirId":"25b5393051b2419e98092570456dd733","actInstId":"7a9ba2fb85614d3f8455242b993b5abe","httpRemoteIp":"10.6.40.22","message":"保存成功!","proInstId":"af5ab4ac9faa4cc98f157aa854812c41"}
            'wfmData': {
              "workitemId": this.wfmData.workitemId,
              "actDefId": this.wfmData.actDefId,
              "configId": this.wfmData.configId,
              "configCode": this.wfmData.configCode,
              "proDirId": this.wfmData.proDirId,
              "actInstId": this.wfmData.actInstId,
              "proInstId": this.wfmData.proInstId
            }
          })
        }
      }).then(({data}) => {
        console.log("结束公文参数data===>>>>: " + JSON.stringify(data));
        if (data.code == 200) {
          let nextActDefIds = data.data.nextActDefIds
          // let currentActDefId = data.data.actDefId
          if (this.util.isNotEmpty(nextActDefIds)) {
            for (var i = 0; i < nextActDefIds.length; i++) {
              // if ("csgwmszz" == nextActDefIds[i].actDefId && currentActDefId.indexOf("scsldsp")>-1) {
              // 	_this.tuiGongWen.push(nextActDefIds[i])
              // }else if("sjzbsgzz" == nextActDefIds[i].actDefId && currentActDefId.indexOf("sjldsh")>-1){
              // 	_this.tuiGongWen.push(nextActDefIds[i])
              // }else if("hqjsr" == nextActDefIds[i].actDefId && currentActDefId.indexOf("scsldhq")>-1){
              // 	_this.tuiGongWen.push(nextActDefIds[i])
              // }
              // _this.tuiGongWen.push(nextActDefIds[0])
              // if(nextActDefIds[i].actType == 'end'){
              // 	_this.endGongWen.push(nextActDefIds[i])
              // }
              if (nextActDefIds[i].actDefId == 'fblc' || nextActDefIds[i].actType == 'fblc') {
                nextActDefIds[i].participants = 'user:' + this.cache.get('userInfo').userId
                _this.endGongWen.push(nextActDefIds[i])
                this.completeWorkitem()
              }

            }
          }
        } else {
          _this.$toast(data.message + ' code:' + data.code)
        }

      })
    },
    //结束公文
    completeWorkitem() {
      console.log("endGongWen: " + JSON.stringify(this.endGongWen));
      const _this = this
      this.$httploading({
        url: this.$http.adornUrl(`/caac/wfm/ApplicationController/completeWorkitem`),
        method: 'post',
        params: {
          'systemKey': this.cache.get('userInfo').systemKey,//固定值
          'systemFlag': this.cache.get('userInfo').systemFlag,//固定值
          data: this.$http.adornData({
            sdForm: this.formData,//详情
            wfmData: {
              "workitemId": this.wfmData.workitemId,
              "actDefId": this.wfmData.actDefId,
              "configId": this.wfmData.configId,
              "proDirId": this.wfmData.proDirId,
              "actInstId": this.wfmData.actInstId,
              "proInstId": this.wfmData.proInstId,
              'nextActivities': _this.endGongWen
            },

          })
        }
      }).then(({data}) => {
        console.log("结束公文data-->>: " + JSON.stringify(data));
        if (data.code == 200) {
          _this.$toast("操作成功")
          uni.redirectTo({
            url: '/pages/caac/receiveMsg/receive-call'
          })

        } else {
          _this.$toast(data.message + ' code:' + data.code)
        }

      })
    },
    //取消按钮
    toClose() {
      this.$emit('closeRegister', '');
    },
    //获取呈送领导和批办人
    approveinfo() {
      const _this = this
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/doc/sd/approveinfo`),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.cache.get('userInfo').systemKey,//固定值
          'systemFlag': this.cache.get('userInfo').systemFlag,//固定值
        })
      }).then(({data}) => {
        //data: {"code":200,"data":{"csld":[],"approve":[]},"message":null}
        console.log("获取呈送领导和批办人-->data: " + JSON.stringify(data));
        if (data.code == 200) {
          if (this.util.isNotEmpty(data.data)) {
            this.csldList = data.data.csld
            this.approveList = data.data.approve
          } else {
            this.$toast('未获取到呈送人员，请联系管理员！')
          }
        }


      })
    },
    //父组件点击登记时调用获取详情回显到表单
    getDetail(fdId, uuid) {
      console.log("fdId: " + fdId + ",uuid:" + uuid);
      this.uuid = uuid
      const _this = this
      this.$httploading({
        url: this.$http.adornUrl(`/caac/oa/doc/sendinfo/listinfo/` + fdId),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.cache.get('userInfo').systemKey,//固定值
          'systemFlag': this.cache.get('userInfo').systemFlag,//固定值
          // 'systemKey': 'ls_liu',//固定值
          // 'systemFlag': 'yidong'//固定值
        })
      }).then(({data}) => {
        console.log("获取收电详情--data: " + JSON.stringify(data));
        if (data.code == 200) {
          this.getCaacBody(data.data.annexId)//获取发送件
          this.getCaacAttachment(data.data.annexId)//获取附件数据
          this.getConfigForStart()//获取提交表单所需参数
          //给formData赋值，回显
          for (let item in this.formData) {
            for (let item2 in data.data) {
              if (item2 == item) {
                this.formData[item] = data.data[item2]
              }
            }
          }
          this.formData.drafterDeptName = data.data.officeDeptName
          console.log("this.formData: " + JSON.stringify(this.formData));
          // this.formData = data.data

        }
      })
    },
    //获取发送件
    getCaacBody(annexId) {
      // fdId = 'c96d8fbcc1f000011ac1cea035606e10'
      const _this = this
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/component/maintext/proInstId/` + annexId),
        method: 'get',
        params: this.$http.adornParams({
          // 'annexId': this.proInstId,
          'systemKey': this.cache.get('userInfo').systemKey,//固定值
          'systemFlag': this.cache.get('userInfo').systemFlag,//固定值
        })
      }).then(({data}) => {
        if (data.code == 200) {
          this.detailBody = data.data
        }
        console.log("获取发送件: " + JSON.stringify(data));
      })
    },
    //获取附件数据
    getCaacAttachment(annexId) {
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/component/attachmentupload/attachmentinfo`),
        method: 'get',
        params: this.$http.adornParams({
          'bizId': annexId,
          'attachTypeId': 'pageBody_uploadFile',
          'systemKey': this.cache.get('userInfo').systemKey,//固定值
          'systemFlag': this.cache.get('userInfo').systemFlag,//固定值
        })
      }).then(({data}) => {
        if (data.code == 200) {
          this.detailAttachment = data.data
        }
      })
    },
    //提交表单所需参数
    getConfigForStart() {
      const _this = this
      this.$http({
        url: this.$http.adornUrl(`/caac/wfm/ApplicationController/getConfigForStart`),
        method: 'post',
        params: this.$http.adornParams({
          'configCode': 'hbgljsdzlc',//固定值
          'systemKey': this.cache.get('userInfo').systemKey,//固定值
          'systemFlag': this.cache.get('userInfo').systemFlag,//固定值
        })
      }).then(({data}) => {
        console.log("签批功能菜单optionBtn01: " + JSON.stringify(data));
        if (data.code == 200) {
          this.configForStart = data.data
        }

      })
    },
    //获取发电头
    fdword() {
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/doc/hbjgj/fd/fdword`),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.cache.get('userInfo').systemKey,//固定值
          'systemFlag': this.cache.get('userInfo').systemFlag,//固定值
          'type': 'sd',//固定值
        })
      }).then(({data}) => {
        //{"code":200,"data":{"fdWord":"华北局收眀电","message":"查询成功!"},"message":null}
        if (data.code == 200) {
          this.formData.sdWord = data.data.fdWord
          this.sdwordnum()
        }
      })
    },
    //获取收电字号
    sdwordnum() {
      const _this = this
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/doc/hbglj/sd/sdwordnum`),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.cache.get('userInfo').systemKey,//固定值
          'systemFlag': this.cache.get('userInfo').systemFlag,//固定值
          'sdWord': this.formData.sdWord,//固定值
          'sdYear': this.formData.sdYear
        })
      }).then(({data}) => {
        //{"code":200,"data":{"sdNum":21,"message":"查询成功!"},"message":null}
        console.log("获取收电字号--data: " + JSON.stringify(data));
        if (data.code == 200) {
          this.formData.sdNum = data.data.sdNum
        }
      })
    },
    //获取需要的字典项
    getDict() {
      const dictSecrecyLevel = this.cache.get('mj')//密级
      //给van-action-sheet 赋值
      this.mj = []
      dictSecrecyLevel.forEach((item) => {
        this.mj.push({name: item.dictItemName, dictItemCode: item.dictItemCode})
      })

      const dictEmergencyLevel = this.cache.get('dbjjcd')//等级
      this.emergencySelect = []
      dictEmergencyLevel.forEach((item) => {
        this.emergencySelect.push({name: item.dictItemName, dictItemCode: item.dictItemCode})
      })

      const dictSource = this.cache.get('source') //来源
      this.sourceSelect = []
      dictSource.forEach((item) => {
        this.sourceSelect.push({name: item.dictItemName, dictItemCode: item.dictItemCode})
      })

      const dictContent = this.cache.get('content') //内容
      this.contentSelect = []
      dictContent.forEach((item) => {
        this.contentSelect.push({name: item.dictItemName, dictItemCode: item.dictItemCode})
      })

      const dictLanguage = this.cache.get('swLanguage') //文种
      this.languageSelect = []
      dictLanguage.forEach((item) => {
        this.languageSelect.push({name: item.dictItemName, dictItemCode: item.dictItemCode})
      })
    },

    changeFn() { // 值变化是触发
      this.changeDate = this.currentDate // Tue Sep 08 2020 00:00:00 GMT+0800 (中国标准时间)
    },
    confirmFn() { // 确定按钮
      this.formData.sdTime = this.util.timeFormatYYYYMMDDHHMMSS(this.currentDate)
      this.showPop = false
    },
    cancelFn() {
      this.showPop = false;
    },
    //获取当前用户所在的处室信息
    cuserdept() {
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/comm/comm/cuserdept`),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.cache.get('userInfo').systemKey,//固定值
          'systemFlag': this.cache.get('userInfo').systemFlag,//固定值
        })
      }).then(({data}) => {
        if (data.code == 200) {
          if (this.util.isNotEmpty(data.data)) {
            this.nodeDataMain.showNode = data.data.deptCode
            this.nodeDataCopy.showNode = data.data.deptCode
            this.nodeDataForward.showNode = data.data.deptCode
          }
        }
      })
    },

  },
}
</script>

<style scoped>
	/* 意见相关样式 */
	.opinion{
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		margin: 0 32rpx;
		padding: 20rpx 0rpx;
		overflow: hidden;
		font-size: 28rpx;
		line-height: 24px;
		border-bottom: 1px solid #ebedf0;

	}
	.opinion .opinion-left{
		text-align: left;
		color: #323233;
	}
	.opinion .opinion-right{
		text-align: right;
		color: #969799;
	}
	/* 修改复选框文字颜色 */
	/deep/ .van-checkbox__label{
		color: #969799;
	}
	/deep/ .van-field__control--right{
		color: #969799;
	}

	/deep/ .van-cell__title {
		min-width: 10%;
	}
	.box-input{
		display: flex;
		flex-direction: row;

		width: 25%;
	}
	.piban-input{
		display: inline;
		width: 35%;
		height: 100%;
		padding-left: 8rpx;
		border: 1rpx solid #ccc;
	}
</style>
